package com.firesyde.gwt.persistence.guice.bdb;

import com.google.inject.Provider;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseConfig;
import com.sleepycat.je.Environment;

public class DatabaseProvider implements Provider<Database> {
	Environment env;
	String dbName;

	public DatabaseProvider(Environment env, String dbName) {
		this.env = env;
		this.dbName = dbName;
	}

	public Database get() {
		try {
			DatabaseConfig dbConfig = new DatabaseConfig();
			dbConfig.setAllowCreate(true);
			Database myDatabase = env.openDatabase(null, dbName,
					dbConfig);
			return myDatabase;
		} catch (Exception e) {

		}
		return null;
	}

}
